package main

import (
	_ "encoding/json"
	"fmt"
	"mypackage/01_struct/vo" // 你的包要放到 $GOPATH/src 路径下面 ，全路径为：C:\Go\src\mypackage\01_struct\vo
)

func main() {
	// 直接使用会报错
	// duck := vo.duck{}//cannot refer to unexported name vo.duck
	duck := vo.DuckFactory("小白鸭", 3)
	fmt.Printf("duck = %v\n", duck)      // duck = &{小白鸭 3}
	fmt.Printf("&duck = %v\n", &duck)    // &duck = 0xc000074018
	fmt.Printf("*duck = %v\n", *duck)    // *duck = {小白鸭 3}
	fmt.Printf("duck type = %T\n", duck) // duck type = *vo.duck

	// 使用公开变量和隐私变量
	fmt.Println("duck.Name = ", duck.Name)
	// 直接使用隐藏变量会报错
	// fmt.Println("duck.age = ", duck.age) //.\main.go:22:33: duck.age undefined (cannot refer to unexported field or method age)
	fmt.Println("duck.age = duck.GetAge() ", duck.GetAge()) //duck.age = duck.GetAge()  3
	duck.SetAge(5)
	fmt.Println("修改后~ duck.GetAge() ", duck.GetAge()) //修改后~ duck.GetAge()  5
}
